package org.tps.project.controllers;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import Project.ejb1.entities.Client;
import Project.ejb1.services.ClientServiceLocal;




@ManagedBean
@SessionScoped
public class NewClientFormulaireController {

	private Client client=new Client();
	private Client clientTemp=new Client();
	
	@EJB
	private ClientServiceLocal clientService;
	
	
	
	public void save() {
		
		
		clientService.create(client);
		client.setRib(1700320000 + client.getIdClient());
		
		clientTemp.setNom(client.getNom());
		clientTemp.setPrenom(client.getPrenom());
		clientTemp.setNumCin(client.getNumCin());
		clientTemp.setRib(client.getRib());
		clientTemp.setSignatureNumerique(client.getSignatureNumerique());
		clientService.update(client); 
		client = new Client();
	}

	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public Client getClientTemp() {
		return clientTemp;
	}

	public void setClientTemp(Client clientTemp) {
		this.clientTemp = clientTemp;
	}
	

}
